﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using QLDAOL.Models;
using QLDAOL.ModelView;
namespace QLDAOL.Controllers
{
    public class ChatController : BaseController
    {
        //
        // GET: /Chat/
        private IEQLDAOLRepository db = new IEQLDAOLRepository();
        public ActionResult Index()
        {

            return View();
        }
        public string chatcontent()
        {
            int pjid = 1;
            string kq = "<div class='chat'>";
            IEnumerable<PJ_CHAT> chats = db.getchatbyPjID(pjid);
            foreach (var chat in chats)
            {
                kq += "<p><span>" + chat.Username + ":<span>&nbsp;" + chat.Description + "</p>";
            }
            kq += "</div>";
            return kq;
        }
        public void insert(string description)
        {
            int pjid = 1;
            string username = Session["user_logon_name"].ToString();
            PJ_CHAT newchat = new PJ_CHAT { 
                Pj_id=pjid,
                Username=username,
                Date=DateTime.Now,
                Description=description
            };
            db.addchat(newchat);

        }

    }
}
